package top.jiug.file.controller;

import com.alibaba.fastjson.JSONObject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import top.jiug.file.config.GetConfig;
import top.jiug.file.entity.User;

import javax.annotation.Resource;

/**
 * 登录 - 控制器
 */
@RestController
public class LoginController {

    @Resource
    private GetConfig getConfig;

    @PostMapping("/login")
    public JSONObject login(@RequestBody User user){
        JSONObject jsonObject = new JSONObject();
        if (getConfig.getUsername().equals(user.getUsername())
        &&getConfig.getPassword().equals(user.getPassword())) {
            jsonObject.put("code",200);
        } else {
            jsonObject.put("code",400);
        }
        return jsonObject;
    }


}
